package com.wanmao.test;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.ListView;

import com.wanmao.test.adapter.InstitutionAdapter;
import com.wanmao.test.model.InstitutionModel;



public class InstitutionListActivity extends BaseActivity {

    private InstitutionAdapter adapter;
    private ListView lv;
    private String fileName;
    private InstitutionModel.TabsBean bean;

    public static void startActivity(Context context, String fileName, InstitutionModel.TabsBean bean) {
        Intent i = new Intent(context, InstitutionListActivity.class);
        i.putExtra("fileName", fileName);
        i.putExtra("content", bean);
        context.startActivity(i);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_institution_list);
        findViewById(R.id.img_back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        lv = (ListView) findViewById(R.id.lv);
        fileName = getIntent().getStringExtra("fileName");
        bean = getIntent().getParcelableExtra("content");
        if (null == bean)
            return;
        adapter = new InstitutionAdapter(this, bean);
        lv.setAdapter(adapter);
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                InstitutionDetailActivity.startActivity(InstitutionListActivity.this, fileName, adapter.getItem(position));
            }
        });
    }
}
